﻿using System;
using System.Collections.Generic;
using System.Text;

namespace com.lover.astd.common.manager
{
    public class TimeMgr
    {
        private static long _timeSpan = 0; // span of time between local and server
        /// <summary>
        /// 当前服务器时间的1970年到现在的毫秒数
        /// </summary>
        public static long TimeStamp
        {
            get
            {
                return Decimal.ToInt64(Decimal.Divide(DateTime.Now.Ticks - 621355968000000000, 10000)) - _timeSpan;
            }
            set
            {
                _timeSpan = Decimal.ToInt64(Decimal.Divide(DateTime.Now.Ticks - 621355968000000000, 10000)) - value;
            }
        }
        /// <summary>
        /// 当前服务器的时间
        /// </summary>
        public static DateTime DateTimeNow
        {
            get { return new DateTime(TimeStamp * 10000 + 621355968000000000); }
        }
    }
}
